package com.yinhai.message.manage.sysapp.dao;

import com.yinhai.core.common.api.base.IPage;
import com.yinhai.core.service.ta3.domain.dao.HibernateDAO;
import com.yinhai.message.core.po.MessageAppManagePo;
import com.yinhai.message.manage.sysapp.vo.SysAppVo;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Map;

/**
 * @author yanglq 2017.3.24
 */
public class SysAppDaoImpl extends HibernateDAO<MessageAppManagePo> implements ISysAppDao {
    @Override
    public MessageAppManagePo saveSysApp(MessageAppManagePo po) {
        save(po);
        return po;
    }

    @Override
    public MessageAppManagePo updateSysApp(MessageAppManagePo po) {
        saveOrUpdate(po);
        return po;
    }


    @Override
    public MessageAppManagePo deleteSysApp(MessageAppManagePo po) {
        delete(po);
        return po;
    }

    @Override
    public IPage<SysAppVo> queryList(String hql, Map<String, Object> param, int start, int limit, String gridId) {
        return super.selectFromMultiTableWithPage(hql, param, start, limit, gridId);
    }

    @Override
    public List<SysAppVo> queryList(String hql) {
        return super.selectFildsList(hql);
    }

    @Override
    public SysAppVo queryOneById(String hsql, String id) {
        return super.selectFiled(hsql, id);
    }

    @Override
    public Long queryCountBySysId(String hql, String systemId, String id) {
        if (StringUtils.isEmpty(id)) {
            return super.getCount(hql, null, systemId);
        }
        return super.getCount(hql, null, systemId, id);
    }

    @Override
    public SysAppVo queryVoBySystemId(String s, String systemId) {
        return super.selectFiled(s, systemId);
    }
}
